package day04.demo

import org.apache.spark.broadcast.Broadcast
import org.apache.spark.{SparkConf, SparkContext}

/**
 * @Author wsl
 * @Description 页面转化率
 */
object TopN_Trans {
  def main(args: Array[String]): Unit = {
    val conf: SparkConf = new SparkConf().setAppName("rdd").setMaster("local[*]")
    val sc = new SparkContext(conf)

    sc.textFile("sparkcore/input/user_visit_action.txt")
      .map(
        line => {
          val word: Array[String] = line.split(" ")
          val city: String = word(1)
          val ad: String = word(4)
          (city + "-" + ad, 1)
        }
      )

    //
    val ids = List("1", "2", "3", "4", "5", "6", "7")
    val zipIds: List[String] = ids.zip(ids.tail).map {
      case (p1, p2) => p1 + "-" + p2
    }

    val bdIds: Broadcast[List[String]] = sc.broadcast(ids)
    val bdZipIds: Broadcast[List[String]] = sc.broadcast(zipIds)



    sc.stop()

  }
}
